package com.jqb.jsplab.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jqb.jsplab.dao.factory.DaoFactory;
import com.jqb.jsplab.dao.proxy.TestDaoProxy;

public class InfoOperateServlet extends HttpServlet {

	private static final long serialVersionUID = -818391886883636615L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String infooperate = null;
		infooperate = request.getParameter("infooperate");
		TestDaoProxy testdaoproxy = null;
		try {
			testdaoproxy = DaoFactory.getInstanceTestDaoProxy();
		} catch (Exception e) {
			e.printStackTrace();
		}
		if ("chat".equals(infooperate)) {
			testdaoproxy.showMessage(request, response);
			request.getRequestDispatcher("/jspdemo/chat.jsp").forward(request, response);
		}
		if ("listtag".equals(infooperate)) {
			testdaoproxy.showTagList(request, response);
			request.getRequestDispatcher("/jspdemo/listtag.jsp").forward(request, response);
		}
		if ("stringsort".equals(infooperate)) {
			testdaoproxy.sortString(request, response);
			request.getRequestDispatcher("/jspdemo/stringsort.jsp").forward(request, response);
		}
	}
}
